<?php

include "../../../lib/start.php";
check_session();
check_permission(DOC_PERM);

$gid = 2;

$sel_docs = "SELECT documents.*, anni.descrizione FROM documents, document_types, anni WHERE doc_type = document_types.id AND document_types.id = ".$_REQUEST['tipo']." AND anni.id_anno = anno_scolastico AND (privato = '0' OR (privato = '1' AND gruppi LIKE '%".$gid."%')) ORDER BY anno_scolastico DESC, data_upload DESC";
$res_docs = $db->execute($sel_docs);

$sel_type = "SELECT * FROM document_types WHERE id = ".$_REQUEST['tipo'];
$res_type = $db->execute($sel_type);
$commento = $res_type->fetch_assoc();

include "documenti.html.php";

?>